/*
 * JTalkerClientUserSelector.java
 *
 * Created on 9. Dezember 2005, 15:23
 */

package com.jtalker.client;

/**
 *
 * @author  admach0
 */
public class JTalkerClientUserSelector extends javax.swing.JDialog {
    
    /** Creates new form JTalkerClientUserSelector */
    public JTalkerClientUserSelector(String _title,
                                     final String [] _source,
                                     String [] _destination) {
        initComponents();
        
        this.setTitle(_title);
        this.setModal(true);
        
                
        
        jListSource.setModel(new javax.swing.AbstractListModel() {
            String[] strings = _source;
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
    private void initComponents() {
        jPanelButtons = new javax.swing.JPanel();
        jButtonOK = new javax.swing.JButton();
        jButtonCANCEL = new javax.swing.JButton();
        jPanelMain = new javax.swing.JPanel();
        jScrollPaneSource = new javax.swing.JScrollPane();
        jListSource = new javax.swing.JList();
        jPanelActionButtons = new javax.swing.JPanel();
        jPanel4 = new javax.swing.JPanel();
        jButtonADD = new javax.swing.JButton();
        jPanel5 = new javax.swing.JPanel();
        jButtonREMOVE = new javax.swing.JButton();
        jPanel6 = new javax.swing.JPanel();
        jScrollPaneDest = new javax.swing.JScrollPane();
        jListDest = new javax.swing.JList();
        jPanelHead = new javax.swing.JPanel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("User Selector");
        jButtonOK.setText("OK");
        jButtonOK.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonOKActionPerformed(evt);
            }
        });

        jPanelButtons.add(jButtonOK);

        jButtonCANCEL.setText("Cancel");
        jButtonCANCEL.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonCANCELActionPerformed(evt);
            }
        });

        jPanelButtons.add(jButtonCANCEL);

        getContentPane().add(jPanelButtons, java.awt.BorderLayout.SOUTH);

        jPanelMain.setLayout(new java.awt.GridLayout(1, 3));

        jScrollPaneSource.setBorder(javax.swing.BorderFactory.createTitledBorder("Source"));
        jListSource.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        jScrollPaneSource.setViewportView(jListSource);

        jPanelMain.add(jScrollPaneSource);

        jPanelActionButtons.setLayout(new java.awt.GridLayout(5, 1));

        
        jPanelActionButtons.add(jPanel4);

        jButtonADD.setText("Add >>");
        jButtonADD.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonADDActionPerformed(evt);
            }
        });

        jPanelActionButtons.add(jButtonADD);

        
        jPanelActionButtons.add(jPanel5);

        jButtonREMOVE.setText("<< Remove");
        jButtonREMOVE.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonREMOVEActionPerformed(evt);
            }
        });

        jPanelActionButtons.add(jButtonREMOVE);

        
        jPanelActionButtons.add(jPanel6);

        jPanelMain.add(jPanelActionButtons);

        jScrollPaneDest.setBorder(javax.swing.BorderFactory.createTitledBorder("Destination"));
        jListDest.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        jScrollPaneDest.setViewportView(jListDest);

        jPanelMain.add(jScrollPaneDest);

        getContentPane().add(jPanelMain, java.awt.BorderLayout.CENTER);

        jPanelHead.setBackground(new java.awt.Color(0, 204, 204));
        getContentPane().add(jPanelHead, java.awt.BorderLayout.NORTH);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButtonCANCELActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCANCELActionPerformed
// TODO add your handling code here:
    }//GEN-LAST:event_jButtonCANCELActionPerformed

    private void jButtonOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonOKActionPerformed
// TODO add your handling code here:
        this.dispose();
    }//GEN-LAST:event_jButtonOKActionPerformed

    private void jButtonREMOVEActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonREMOVEActionPerformed
// TODO add your handling code here:
    }//GEN-LAST:event_jButtonREMOVEActionPerformed

    private void jButtonADDActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonADDActionPerformed
// TODO add your handling code here:
    }//GEN-LAST:event_jButtonADDActionPerformed
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                String [] values = {"1", "2"};
                String [] retVal = null;
                new JTalkerClientUserSelector("Select users", values, retVal).setVisible(true);
                
                System.out.println("Return");
            }
        });
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButtonADD;
    private javax.swing.JButton jButtonCANCEL;
    private javax.swing.JButton jButtonOK;
    private javax.swing.JButton jButtonREMOVE;
    private javax.swing.JList jListDest;
    private javax.swing.JList jListSource;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanelActionButtons;
    private javax.swing.JPanel jPanelButtons;
    private javax.swing.JPanel jPanelHead;
    private javax.swing.JPanel jPanelMain;
    private javax.swing.JScrollPane jScrollPaneDest;
    private javax.swing.JScrollPane jScrollPaneSource;
    // End of variables declaration//GEN-END:variables
    
}
